<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/

Route::get('/', 'HomeController@index');

Route::group(['prefix' => 'm'],function() {
    Route::get('home', ['as'=>'M.Home.index','uses'=>'HomeController@index']);
    Route::get('goods',['as'=>'M.Home.goods','uses'=>'HomeController@goods']);
    Route::get('goods-detail',['as'=>'M.Home.goodsDetail','uses'=>'HomeController@goodsDetail']);
    Route::get('confirm',['as'=>'M.Home.confirm','uses'=>'HomeController@confirm']);
    Route::get('choice-address',['as'=>'M.Home.choiceAddress','uses'=>'HomeController@choiceAddress']);
    Route::get('add-address',['as'=>'M.Home.addAddress','uses'=>'HomeController@addAddress']);
    Route::get('pay-info',['as'=>'M.Home.payInfo','uses'=>'HomeController@payInfo']);
    Route::get('order-list',['as'=>'M.Home.orderList','uses'=>'HomeController@orderList']);
    Route::get('user-center', ['as' => 'M.Home.userCenter', 'uses' => 'HomeController@userCenter']);
    Route::get('kefu', ['as' => 'M.Home.kefu', 'uses' => 'HomeController@kefu']);
    Route::get('login', ['as' => 'M.Home.login', 'uses' => 'HomeController@login']);
    Route::get('register', ['as' => 'M.Home.signUp', 'uses' => 'HomeController@signUp']);
    Route::get('login-out', ['as' => 'M.Home.signOut', 'uses' => 'HomeController@signOut']);
    Route::get('user-address', ['as' => 'M.Home.userAddress', 'uses' => 'HomeController@userAddress']);
    Route::get('content-detail', ['as' => 'M.Home.contentDetail', 'uses' => 'HomeController@contentDetail']);
    Route::get('payTest', ['as' => 'M.Home.payTest', 'uses' => 'HomeController@payTest']);
});

Route::group(['prefix'=>'admin'],function(){
    Route::get('create-content',['as'=>'Admin.Content.createContent','uses'=>'AdminController@createContent']);
    Route::get('create-good',['as'=>'Admin.Content.createGood','uses'=>'AdminController@createGood']);
    Route::get('phone-msg',['as'=>'Admin.Content.phoneMsg','uses'=>'AdminController@phoneMsg']);
});

Route::group(['prefix' => 'api', 'namespace'=>'Api', 'middleware' => ['web','cors']],function() {

    /** 获取系统token */
    Route::get('get-csrf-token', ['as' => 'Api.General.GetCsrfToken', 'uses' => 'GeneralController@getCsrfToken']);
    /** 获取系统时间 */
    Route::get('get-sys-time', ['as' => 'Api.General.getSystemTime', 'uses' => 'GeneralController@getSystemTime']);

    /** 图片上传和显示接口 */
    Route::group(['prefix' => 'auth'],function(){
        /** 通过手机获取短信验证码接口 20160803 */
        Route::post('get-verify-code-by-phone', ['as' => 'Api.Auth.getVerifyCodeByPhone', 'uses' => 'AuthController@getVerifyCodeByPhone']);
        Route::get('login-out', ['as' => 'Api.Auth.signOut', 'uses' => 'AuthController@signOut']);
        Route::post('login-in', ['as' => 'Api.Auth.SignIn', 'uses' => 'AuthController@SignIn']);
//        Route::post('sign-up', ['as' => 'Api.Auth.signUp', 'uses' => 'AuthController@signUp']);
        Route::post('sign-up', ['as' => 'Api.Auth.getCurrentUserId', 'uses' => 'AuthController@getCurrentUserId']);
        Route::get('wechat-login', ['as' => 'Api.Auth.wechatLogin', 'uses' => 'AuthController@wechatLogin']);
        Route::get('wechat-callback', ['as' => 'Api.Auth.wechatCallback', 'uses' => 'AuthController@wechatCallback']);
        Route::get('get-userinfo', ['as' => 'Api.Auth.getUserInfo', 'uses' => 'AuthController@getUserInfo']);
    });

    Route::group(['prefix' => 'design'],function(){
        Route::get('get-color-list', ['as' => 'Api.Design.getColorImgList', 'uses' => 'DesignController@getColorImgList']);
        Route::get('get-material', ['as' => 'Api.Design.getMaterial', 'uses' => 'DesignController@getMaterial']);
        Route::get('get-template', ['as' => 'Api.Design.getDesignTemplate', 'uses' => 'DesignController@getDesignTemplate']);
        Route::post('build-new', ['as' => 'Api.Design.buildCompositeImg', 'uses' => 'DesignController@buildCompositeImg']);
        Route::get('get-build-by-code', ['as' => 'Api.Design.getBuildDesignByCode', 'uses' => 'DesignController@getBuildDesignByCode']);
        Route::post('build-order', ['as' => 'Api.Design.buildOrder', 'uses' => 'DesignController@buildOrder']);
        Route::get('setRewardFollow', ['as' => 'Api.Design.setRewardFollow', 'uses' => 'DesignController@setRewardFollow']);
        Route::post('support-design', ['as' => 'Api.Design.supportDesign', 'uses' => 'DesignController@supportDesign']);
        Route::post('get-support-num', ['as' => 'Api.Design.getSupportNum', 'uses' => 'DesignController@getSupportNum']);
        Route::post('build-share-image', ['as' => 'Api.Design.buildShareImage', 'uses' => 'DesignController@buildShareImage']);
        Route::post('testBuildTshirt', ['as' => 'Api.Design.testBuildTshirt', 'uses' => 'DesignController@testBuildTshirt']);
        Route::get('is-in-active', ['as' => 'Api.Design.isInActive', 'uses' => 'DesignController@isInActive']);
        Route::get('get-active-status', ['as' => 'Api.Design.getActiveStatus', 'uses' => 'DesignController@getActiveStatus']);
        Route::post('sendExpressSms', ['as' => 'Api.Design.sendExpressSms', 'uses' => 'DesignController@sendExpressSms']);
    });

    Route::group(['prefix' => 'payment'],function(){
        Route::post('payByWechatJsApi', ['as' => 'Api.Payment.payByWechatJsApi', 'uses' => 'PaymentController@payByWechatJsApi']);
        Route::any('wechatPayCallBack', ['as' => 'Api.Payment.wechatPayCallBack', 'uses' => 'PaymentController@wechatPayCallBack']);
        Route::post('checkPayResult', ['as' => 'Api.Payment.checkPayResult', 'uses' => 'PaymentController@checkPayResult']);
    });

    Route::group(['prefix' => 'wechat'],function(){
        Route::post('packTest', ['as' => 'Api.Wechat.packTest', 'uses' => 'WechatController@packTest']);
        Route::post('getJsApiPacket', ['as' => 'Api.Wechat.getJsApiPacket', 'uses' => 'WechatController@getJsApiPacket']);
    });

    Route::group(['prefix' => 'order'],function(){
        Route::post('build-order-item', ['as' => 'Api.Order.buildOrderItem', 'uses' => 'OrderController@buildOrderItem']);
        Route::post('change-order-item-num', ['as' => 'Api.Order.changeOrderItemNum', 'uses' => 'OrderController@changeOrderItemNum']);
        Route::post('confirm-order', ['as' => 'Api.Order.confirmOrder', 'uses' => 'OrderController@confirmOrder']);
    });

    Route::group(['prefix' => 'user'],function(){
        Route::post('add-address', ['as' => 'Api.User.addAddress', 'uses' => 'UserController@addAddress']);
        Route::post('del-user-address', ['as' => 'Api.User.delUserAddress', 'uses' => 'UserController@delUserAddress']);
        Route::get('set-user-phone', ['as' => 'Api.User.setPhoneMsg', 'uses' => 'UserController@setPhoneMsg']);
    });

    /** 图片上传和显示接口 */
    Route::group(['prefix' => 'file'],function(){
        /** 输出原图片接口 */
        Route::get('image/{id}',['as'=>'Api.File.Image.Show','uses'=>'ImageController@showImageById']);
        /** 输出不同尺寸图片接口 */
        Route::get('{id}/show/{px}',['as'=>'Api.Image.ShowPX','uses'=>'ImageController@getImageBinAsShowById']);
        /** 剪裁图片接口 */
        Route::post('crop-image',['as'=>'Api.Image.CropImage','uses'=>'ImageController@CropImage']);
        /** 多图上传接口 */
        Route::post('upload-images',['as'=>'Api.Image.uploadImages','uses'=>'ImageController@uploadImages']);

        /** 上传图片接口 */
        Route::post('upload-image',['as'=>'Api.Upload.Image','uses'=>'ImageController@upload']);
        Route::get('qrcode',['as'=>'Api.Upload.qrcode','uses'=>'ImageController@qrcode']);
        Route::get('download-image/{id}',['as'=>'Api.Upload.downloadImage','uses'=>'ImageController@downloadImage']);
        Route::get('getImgUrlById',['as'=>'Api.Upload.getImgUrlById','uses'=>'ImageController@getImgUrlById']);
    });


    Route::group(['prefix' => 'article'],function(){
        Route::post('build-article',['as'=>'Api.Article.buildArticle','uses'=>'ArticleController@buildArticle']);
    });

    Route::group(['prefix'=>'good'],function(){
        Route::post('create-good',['as'=>'Api.Good.createGood','uses'=>'GoodsController@createGood']);
    });

    Route::group(['prefix' => 'code'],function(){
        Route::any('updateZY',['as'=>'Api.Code.updateZY','uses'=>'CodeController@updateZY']);
        Route::any('updateZYW',['as'=>'Api.Code.updateZYW','uses'=>'CodeController@updateZYW']);
        Route::any('test',function (){
            $aa = \App\Http\Services\FileManager::buildQrcode('http://baidu.com');
            return $aa;
        });
    });

});
